<?php

namespace App\Models;

class UsersCollModel
{
    /**
     * 插入用户付款信息
     * entry conn,token
     * return int
     * */
    public static function insertUsersCollInside($conn,$uid){
        $insertSql = "insert into `users_coll`(`uid`)value($uid)";
        return $conn->executeConn($insertSql);
    }
    /**
     * 获取用户付款信息
     * entry conn,token
     * return int
     * */
    public static function getUsersCollInside($conn,$uid){
        $querySql="SELECT `account`,`name`,`bank`,`branch`,`wechat`,`alipay` FROM `users_coll` WHERE  `uid` = $uid";
        return $conn->readConn($querySql);
    }
    /**
     * 修改公告可添加字段
     * entry UsersCollExample
     * return int
     * */
    public static function editInside($conn,$Example){
        $joinSql="";
        if($Example->account !=null){
            $joinSql.=" `account` = '$Example->account',";
        }else{
            $joinSql.=" `account` = null,";
        }
        if($Example->name !=null){
            $joinSql.=" `name` = '$Example->name',";
        }else{
            $joinSql.=" `name` = null,";
        }
        if($Example->bank !=null){
            $joinSql.=" `bank` = '$Example->bank',";
        }else{
            $joinSql.=" `bank` = null,";
        }
        if($Example->branch !=null){
            $joinSql.=" `branch` = '$Example->branch',";
        }else{
            $joinSql.=" `branch` = null,";
        }
        if($Example->wechat !=null){
            $joinSql.=" `wechat` = '$Example->wechat',";
        }else{
            $joinSql.=" `wechat` = null,";
        }
        if($Example->alipay !=null){
            $joinSql.=" `alipay` = '$Example->alipay',";
        }else{
            $joinSql.=" `alipay` = null,";
        }
        if($joinSql !=null){
            $innerJoin = rtrim($joinSql,",");
            $upUserSql="UPDATE  `users_coll` SET $innerJoin WHERE `uid` = '$Example->uid'";
            return $conn->executeConn($upUserSql);
        }
    }
}